# All relevant packages
packages <- c("quanteda", "readtext", "plyr", "dplyr", "stringr", "stringi",
              "ggplot2", "ggfortify", "tidyr", "tm", "haven", "lmtest",
              "caret", "caretEnsemble", "tidyverse", "data.table",
              "survival", "lme4", "performance", "sandwich",
              "foreach", "doParallel", "keyATM", "lubridate", "broom",
              "xtable", "MASS", "xtable", "pacman", "stargazer", "glmmTMB", "crfsuite")

# Install packages not yet installed
installedPackages <- packages %in% rownames(installed.packages())
if (any(installedPackages == FALSE)) {
  install.packages(packages[!installedPackages])
}

# Load packages
invisible(lapply(packages, library, character.only = TRUE))